home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part1 / 1046 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.7 KB

  1. Path: unsw.edu.au!gwong
  2. From: gwong@cse.unsw.edu.au (Geoffrey  Wong)
  3. Newsgroups: comp.lang.c
  4. Subject: QUESTION about pointers and structures
  5. Date: 11 Jan 1996 02:14:40 GMT
  6. Organization: University of New South Wales
  7. Message-ID: <4d1rqg$bse@mirv.unsw.edu.au>
  8. NNTP-Posting-Host: thesis.circus.cse.unsw.edu.au
  9. X-Newsreader: TIN [version 1.2 PL2]
  10.  
  11. Hi guys,
  12.     I am wondering if anyone of you c legends could help me. I have a
  13.     rather complex data structure.
  14.     It is a pointer to structure which contains pointer to structures.
  15.     I don't know if I need to allocate space for variables of this complex
  16.     type before I can do the assignments.
  17.     
  18.     I have a variable called background.
  19.     declared as:-
  20.     SLiteral        *background; 
  21.     
  22.     Now SLiteral is:-
  23.     
  24.     typedef struct _slit_rec        *SLiteral,      /* Used in rlgg */
  25.  
  26.     
  27.     and _slit_rec is:-
  28.     
  29.     struct _slit_rec
  30.  
  31. {
  32.  
  33.     char            Sign;           /* 0=negated, 1=pos, 2=determinate */
  34.  
  35.     Relation        Rel;
  36.  
  37.     Const           *Constants; /* During an rlgg process Constant and Var is 
  38.  
  39.                     coded using the same data type. This is 
  40.  
  41.                     possible since Const is larger than Var! */
  42.  
  43.     Which           *ConstVar;      /* 0=const, 1=Var  for each Constants */
  44.  
  45.     int             WeakLits;       /* value up to this literal */
  46.  
  47.     Ordering        *ArgOrders,     /* recursive lits: =, <, >, # */
  48.  
  49.             *SaveArgOrders; /* copy during pruning */
  50.  
  51.     float           Bits;           /* encoding length */
  52.  
  53. };
  54.  
  55.  
  56.  
  57.  
  58. Now my question is can I just say background[i]->Sign = ???? or do I need to
  59.  
  60. allocate space for background[i] or do I need to allocate space for *background
  61.  
  62.  
  63.  
  64. Any help would be appreciated, I am rather new to c, don't know much tricks
  65.  
  66. yet.
  67.  
  68.  
  69.  
  70. geoff.
  71.  
  72.  
  73.